package com.test.web.controller.vue;

import com.he.core.ResultT;
import com.he.web.annotation.NeedToken;
import com.test.web.controller.base.BaseController;
import com.test.web.entity.Menu;
import com.test.web.service.MenuService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author heyanjing
 * date:2020-06-09 2020/6/9:22:54
 */
@Slf4j
@AllArgsConstructor
@RestController
public class MenuController extends BaseController {

    @Autowired
    private MenuService menuService;

    @PostMapping("/menu/insert")
    public ResultT login(@RequestBody Menu menu) throws Exception {
        return menuService.insert(menu);
    }


    @PostMapping("/menu/update")
    public ResultT update(@RequestBody Menu menu) throws Exception {
        return menuService.update(menu);
    }

    @GetMapping("/menu/delete")
    public ResultT delete(String menuId) throws Exception {
        return menuService.delete(menuId);
    }

    @NeedToken(false)
    @GetMapping("/menu/find")
    public ResultT<List<Menu>> find() throws Exception {
        return menuService.find();
    }

    @GetMapping("/menu/list")
    public ResultT<List<Menu>> list() throws Exception {
        return menuService.list();
    }

}
